{extend name="public/father" /}

{block name='main'}
<div class="layui-card">
    <div class="layui-card-header">回退跳转管理</div>
    <div class="layui-card-body">

        <blockquote class="layui-elem-quote layui-quote-nm">使用前，请先添加域名｛类型：跳转域名｝，支持泛域名</blockquote>

        <div class="layui-btn-container">
            <button class="layui-btn" onclick="openUrl('添加', 'create', 800);return false;"><i class="layui-icon layui-icon-addition"></i>添加回退跳转</button>
            <button class="layui-btn layui-btn-primary" onclick="javascript:location.reload();"><i class="layui-icon layui-icon-ok-circle"></i> 刷新</button>
            <button class="layui-btn layui-btn-danger" onclick="openUrl('添加', '/admin/domain/create', 800);return false;"><i class="layui-icon layui-icon-addition"></i>添加域名</button>
        </div>

        <table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>

        <script type="text/html" id="status">
            {{ d.status==1 ? '已启用' : '<span style="color: orange;">已禁用</span>' }}
        </script>

        <script type="text/html" id="rukou">

            <div class="layui-btn-group">
                <a class="layui-btn layui-btn-sm layui-btn-primary" href="{{tihuan(d.domain)}}/u/{{ d.id }}" target="_blank">
                    <i class="layui-icon layui-icon-link"></i>打开
                </a>

                <a class="layui-btn layui-btn-sm layui-btn-primary"
                   onclick="showImg('https://minico.qq.com/qrcode/get?type=2&r=2&size=200&text={{tihuan(d.domain)}}/u/{{ d.id }}')">
                    <i class="layui-icon layui-icon-chart"></i>二维码
                </a>

                <a class="layui-btn layui-btn-sm layui-btn-primary"
                   onclick="layer.alert('{{tihuan(d.domain)}}/u/{{ d.id }}', {title: false,shade: 0.5,closeBtn: 1,shadeClose: true,anim: 3,btn:false});">
                    <i class="layui-icon layui-icon-search"></i>网址
                </a>
            </div>

        </script>

        <script type="text/html" id="barDemo">
            <div class="layui-btn-group">
                <a class="layui-btn layui-btn-sm layui-btn-primary" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>修改</a>
                <a class="layui-btn layui-btn-sm layui-btn-primary" lay-event="del" data-table="jumps"><i class="layui-icon layui-icon-delete"></i>删除</a>
            </div>
        </script>

    </div>
</div>
{/block}


{block name="js"}
<script type="text/javascript">
    layui.use(['table'], function() {
        var table = layui.table,
            $ = layui.jquery;

        table.render({
            elem: '#dataTable',
            url: "{:url()}",
            title: '数据表',
            cellMinWidth: 200,
            size: 'lg',
            limit: 50,
            // height: 'full-300',
            cols: [[
					{field:'left',	title:'操作',	totalRowText:'操作',	width:160,	align:'center',	toolbar:'#barDemo'},
					{field:'status',title:'状态',	totalRowText:'状态',	width:100,	align:'center',	sort:true,	templet:'#status'},
					{field:'name',	title:'项目标签',	totalRowText:'项目标签',	width:200,	align:'center',	sort:true},
					{field:'rukou',	title:'入口网址',	totalRowText:'入口网址',	width:240,	align:'center',	templet:'#rukou'},
					{field:'view',	title:'访问量',	totalRowText:'访问量',	width:100,	align:'center',	sort:true},
			{field: 'create_time',	title:'更新时间',	totalRowText:'更新时间',	width:170,	align:'center',	sort:true},
                ]],
            page: true
        });

    });


    /*随机一个字符*/
    function a(a) {
        var d,
            e,
            b = "qwertyuiopasdfghjklzxcvbnm0123456789",
            c = "";
        for(d = 0; a > d; d += 1)
            e = Math.random() * b.length, e = Math.floor(e), c += b.charAt(e);
        return c
    }

    function tihuan(url) {

        if ( url == undefined ){
            return '';
        }

        if ( url ){
            return 'http://' + url.domain.replace(/\*/g, a(6));
        }

    }

</script>
{/block}
